//-----------------------------------------------------------------------
// <copyright file="UserPermissionService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class UserPermissionService
    {
        #region UserPermission

        public static void CreateUserPermission(UserPermission userPermission)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                userPermissionDAO.CreateUserPermission(userPermission);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateUserPermissionException, ex);
            }
        }        

        public static void UpdateUserPermission(UserPermission userPermission)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                userPermissionDAO.UpdateUserPermission(userPermission);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateUserPermissionException, ex);
            }
        }        

        public static void DeleteUserPermission(int userPermissionId)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                userPermissionDAO.DeleteUserPermission(userPermissionId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteUserPermissionException, ex);
            }
        }
        
        public static UserPermission GetUserPermission(int userPermissionId)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                return userPermissionDAO.GetUserPermission(userPermissionId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserPermissionException, ex);
            }
        }                

        public static UserPermissionCollection GetUserPermissionList(UserPermissionColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                return userPermissionDAO.GetUserPermissionList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserPermissionListException, ex);
            }
        }        

        public static UserPermissionCollection GetUserPermissionList(UserPermissionColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                return userPermissionDAO.GetUserPermissionList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserPermissionListException, ex);
            }
        }        

	    public static UserPermissionCollection GetUserPermissionListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                return userPermissionDAO.GetUserPermissionListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserPermissionListException, ex);
            }
        }        

        public static UserPermissionCollection GetUserPermissionListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                UserPermissionDAO userPermissionDAO = new UserPermissionDAO();
                return userPermissionDAO.GetUserPermissionListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserPermissionListException, ex);
            }
        }        

        #endregion
    }
}